package com.example.mr.sort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author lbq
 * @version 1.0
 * @date 2021/11/5 0:38
 */
public class WordSortReducer extends Reducer<IntWritable, IntWritable, Text, NullWritable> {

    private final Text text = new Text();
    private volatile int start = 1;

    @Override
    protected void reduce(IntWritable key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        text.set(start + "\t" + key.get());
        context.write(text, NullWritable.get());
        start++;
    }
}
